package customadapter.example;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Gallery;
import android.widget.Toast;


public class VersionesGalleryActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.simplelist);
		setContentView(R.layout.gallery);
		ArrayList<AndroidVersion> versiones = new ArrayList<AndroidVersion>();
		versiones.add(new AndroidVersion("Android", "" , R.drawable.icon));
		versiones.add(new AndroidVersion("CupCake", "1.5", R.drawable.icon));
		versiones.add(new AndroidVersion("Donut","1.6", R.drawable.icon));
		versiones.add(new AndroidVersion("Eclair", "2.0/2.1",R.drawable.icon));
		Gallery gallery = (Gallery)findViewById(android.R.id.list);
		VersionesAdapter adapter =new VersionesAdapter(VersionesGalleryActivity.this, versiones);
		gallery.setAdapter(adapter);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menuprincipal, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
			case R.id.menuAcercaDe:
				String aboutTxt =  "(c) 2010 Master-D";
				Toast.makeText(VersionesGalleryActivity.this, aboutTxt, Toast.LENGTH_LONG).show();
				return true;
			case R.id.menuQuit:
				finish();
				return true;
			default:
				return false;
		}
	}
}
